//
//  YMJlrc.m
//  音频播放测试
//
//  Created by dllo on 16/7/29.
//  Copyright © 2016年 YMJ. All rights reserved.
//

#import "YMJlrc.h"

@implementation YMJlrc
- (instancetype)init {
    self = [super init];
    if (self) {
        _timeArr = [NSMutableArray array];
        _lyricArr = [NSMutableArray array];
    }
    return self;
}
- (NSString *)getLyricPath {
    return [[NSBundle mainBundle] pathForResource:@"世界上最难唱的歌" ofType:@"lrc"];

}
- (void)papareLyric {
    NSString *fileStr = [NSString stringWithContentsOfFile:[self getLyricPath] encoding:NSUTF8StringEncoding error:nil];
    NSArray *dataArray = [fileStr componentsSeparatedByString:@"\n"];
//    NSLog(@"%@",dataArray);
//    self.timeArr = [NSMutableArray array];
//    self.lyricArr = [NSMutableArray array];
    for (NSString *str in dataArray) {
        if (!str.length == 0) {
            // 解析时间
            NSString *timeStr = [str substringWithRange:NSMakeRange(1, 8)];
            [_timeArr addObject:timeStr];
            // 解析歌词
            NSString *lyricStr = [str substringFromIndex:10];
            [_lyricArr addObject:lyricStr];
        }
    }
    NSLog(@"时间%@",_timeArr);
    NSLog(@"歌词%@",_lyricArr);
}
@end
